﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Dack_Web2.DTO;
using System.Data.OleDb;

namespace Dack_Web2.DAO
{
    public class LoaiSanPhamDAO
    {
        public void Insert(LoaiSanPhamDTO tmp)
        {
            OleDbConnection cn = Sql_DataProvider.SQLConnect();
            string str = "insert into LoaiSanPham(TenLoaiSanPham) values (@TenLoaiSanPham)";
            OleDbCommand cmd = new OleDbCommand(str, cn);

            OleDbParameter para1 = new OleDbParameter("@TenLoaiSanPham", tmp.TenLoaiSanPham);

            cmd.Parameters.Add(para1);

            cmd.ExecuteNonQuery();

            cn.Close();
        }

        public void Update(LoaiSanPhamDTO tmp)
        {
            OleDbConnection cn = Sql_DataProvider.SQLConnect();
            string str = "update GioHang set TenLoaiSanPham=@TenLoaiSanPham where MaLoaiSanPham=@MaLoaiSanPham";
            OleDbCommand cmd = new OleDbCommand(str, cn);

            OleDbParameter para1 = new OleDbParameter("@TenLoaiSanPham", tmp.TenLoaiSanPham);
            OleDbParameter para2 = new OleDbParameter("@MaLoaiSanPham", tmp.MaLoaiSanPham);
            
            cmd.Parameters.Add(para1);
            cmd.Parameters.Add(para2);

            cmd.ExecuteNonQuery();

            cn.Close();
        }

        public void Delete(LoaiSanPhamDTO tmp)
        {
            OleDbConnection cn = Sql_DataProvider.SQLConnect();
            string str = "delete from GioHang where MaLoaiSanPham=@MaLoaiSanPham";
            OleDbCommand cmd = new OleDbCommand(str, cn);

            OleDbParameter para1 = new OleDbParameter("@MaLoaiSanPham", tmp.MaLoaiSanPham);

            cmd.Parameters.Add(para1);

            cmd.ExecuteNonQuery();

            cn.Close();
        }
    }
}